package project.newCode.bbhierarchy;
import java.util.ArrayList;

import project.newCode.*;
import project.newCode.surfaces.*;
public class SimplestHierarchy implements Hittable{

	ArrayList<Hittable> contents;
	public SimplestHierarchy(ArrayList<Hittable> contents2) {
		contents = contents2;
	}

	@Override
	public boolean hit(Ray hittingray, double t0, double t1, Hitrecord rec) {
		Hitrecord trec = new Hitrecord();
		double tstart = t0;
		double tend = t1;
		boolean hit = false;
		for(Hittable s : contents) {
			if(s.boundingbox().hit(hittingray, tstart, tend, trec)){
				if(s.hit(hittingray, tstart, tend, trec)) {
					hit = true;
					trec.copyInto(rec);
					tend=trec.t;
				}
			}
		}
		return hit;
	}

	@Override
	public Box boundingbox() {
		// TODO Auto-generated method stub
		return null;
	}

}
